<?php

/*
 * Запросы к БД
 * Используется PDO, инкапсулирует в себе PDOStatement
 * 
 */

namespace T4\DB;

use \T4\Exception as Exception;
use \PDOStatement;
use T4\Debug;

class Statement {
	
	protected $statement;
	
	public function __construct( PDOStatement $statement ) {
		$this->statement = $statement;
	}
	
	public function getQueryString() {
		return $this->statement->queryString;
	}
	
	public function execute($inputParams = array()) {
		
		if (DEBUG)
			Debug::timerBegin();
		
		$result = $this->statement->execute($inputParams);
		
		if (DEBUG)
			Debug::logSQL($this->getQueryString(), Debug::timerEnd());
		
		return $result;
		
	}
	
	public function fetch($style) {
		return $this->statement->fetch($style);
	}
	
	public function fetchAll($style) {
		return $this->statement->fetchAll($style);
	}
	
	public function columnCount() {
		return $this->statement->columnCount();
	}
	
}